﻿import com.gamepackage.tilemap.*;

class com.gamepackage.tilemap.layer.ChildSprite implements com.gamepackage.tilemap.Moveable
{
	private var x: Number, y: Number;
	
	private var linkageId: String;
	
	private var parent: MovieClip;
	private var timeline: MovieClip;
	private var depth: Number;
	
	private var layer: Layer;

	function ChildSprite( layer: Layer )
	{
		this.layer = layer;
	}
	
	function attach( linkageId: String ): Void
	{
		parent = layer.getChildMovieClip();
		timeline = parent.attachMovie( this.linkageId = linkageId , linkageId , 0 );
		trace( timeline );
	}
	
	function remove( Void ): Void
	{
		timeline.removeMovieClip();
	}
	
	function moveTo( x: Number, y: Number ): Void
	{
		parent._x = this.x = x;
		parent._y = this.y = y;
		
		//-- Z --//
		parent._y += arguments[2];
	}
	
	function zSort( row:Number ): Void
	{
		parent.swapDepths( TileLayer( layer ).getRowDepth( row ) );
	}
	
	function getLoaderClip( Void ): MovieClip
	{
		return parent;
	}
	
	function getTimeline( Void ): MovieClip
	{
		return timeline;
	}
	
	function getX( Void ): Number
	{
		return x;
	}
	function getY( Void ): Number
	{
		return y;
	}
}